<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>productlog管理</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!-- 引入样式 -->
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
    <link rel="stylesheet" href="../plugins/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="../css/style.css">

    <!-- 上传图片框样式，不使用上传组件可以删除此样式 -->
    <style>
        .avatar-uploader .el-upload {
            border: 1px dashed #d9d9d9;
            border-radius: 6px;
            cursor: pointer;
            position: relative;
            overflow: hidden;
        }
        .avatar-uploader .el-upload:hover {
            border-color: #409EFF;
        }
        .avatar-uploader-icon {
            font-size: 28px;
            color: #8c939d;
            width: 150px;
            height: 70px;
            line-height: 150px;
            text-align: center;
        }
        .avatar {
            width: 150px;
            height: 70px;
            display: block;
        }

    </style>
</head>
<body class="hold-transition">
<div id="app">

    <div class="content-header">
        <h1>管理<small>productlog管理</small></h1>
        <el-breadcrumb separator-class="el-icon-arrow-right" class="breadcrumb">
            <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item>管理</el-breadcrumb-item>
            <el-breadcrumb-item>productlog管理</el-breadcrumb-item>
        </el-breadcrumb>
    </div>

    <div class="app-container">
        <div class="box">
            <div class="filter-container">
                <!--查询表单-->
                <el-form :inline="true" >
                          <el-form-item label="spu商品的id">
<el-input v-model="searchMap.spuId" placeholder="spu商品的id" class="filter-item" ></el-input></el-form-item>
          <el-form-item label="原价格">
<el-input v-model="searchMap.priceBef" placeholder="原价格" class="filter-item" ></el-input></el-form-item>
          <el-form-item label="现价格">
<el-input v-model="searchMap.priceNow" placeholder="现价格" class="filter-item" ></el-input></el-form-item>
          <el-form-item label="促销前">
<el-input v-model="searchMap.onSaleBef" placeholder="促销前" class="filter-item" ></el-input></el-form-item>
          <el-form-item label="促销后">
<el-input v-model="searchMap.onSaleNow" placeholder="促销后" class="filter-item" ></el-input></el-form-item>
          <el-form-item label="赠送匠币前">
<el-input v-model="searchMap.presBef" placeholder="赠送匠币前" class="filter-item" ></el-input></el-form-item>
          <el-form-item label="赠送匠币后">
<el-input v-model="searchMap.presNow" placeholder="赠送匠币后" class="filter-item" ></el-input></el-form-item>
          <el-form-item label="匠币购买金额前">
<el-input v-model="searchMap.buyBef" placeholder="匠币购买金额前" class="filter-item" ></el-input></el-form-item>
          <el-form-item label="匠币购买金额后">
<el-input v-model="searchMap.buyNow" placeholder="匠币购买金额后" class="filter-item" ></el-input></el-form-item>
          <el-form-item label="原上架状态">
<el-input v-model="searchMap.isMarketableBef" placeholder="原上架状态" class="filter-item" ></el-input></el-form-item>
          <el-form-item label="现上架状态">
<el-input v-model="searchMap.isMarketableNow" placeholder="现上架状态" class="filter-item" ></el-input></el-form-item>
          <el-form-item label="原审核状态">
<el-input v-model="searchMap.statusBef" placeholder="原审核状态" class="filter-item" ></el-input></el-form-item>
          <el-form-item label="现审核状态">
<el-input v-model="searchMap.statusNow" placeholder="现审核状态" class="filter-item" ></el-input></el-form-item>
          <el-form-item label="审核人员">
<el-input v-model="searchMap.auditor" placeholder="审核人员" class="filter-item" ></el-input></el-form-item>
          <el-form-item label="审核时间">
<el-input v-model="searchMap.auditTime" placeholder="审核时间" class="filter-item" ></el-input></el-form-item>

                <el-button class="dalfBut" @click="fetchData()">查询</el-button>
                <el-button type="primary"  class="butT" @click="formVisible=true;pojo={}">新增</el-button>
                </el-form>
            </div>

            <el-table :data="tableData" border style="width: 100%">
                          <el-table-column prop="id" label="id" width="80"></el-table-column>
          <el-table-column prop="spuId" label="spu商品的id" width="80"></el-table-column>
          <el-table-column prop="priceBef" label="原价格" width="80"></el-table-column>
          <el-table-column prop="priceNow" label="现价格" width="80"></el-table-column>
          <el-table-column prop="onSaleBef" label="促销前" width="80"></el-table-column>
          <el-table-column prop="onSaleNow" label="促销后" width="80"></el-table-column>
          <el-table-column prop="presBef" label="赠送匠币前" width="80"></el-table-column>
          <el-table-column prop="presNow" label="赠送匠币后" width="80"></el-table-column>
          <el-table-column prop="buyBef" label="匠币购买金额前" width="80"></el-table-column>
          <el-table-column prop="buyNow" label="匠币购买金额后" width="80"></el-table-column>
          <el-table-column prop="isMarketableBef" label="原上架状态" width="80"></el-table-column>
          <el-table-column prop="isMarketableNow" label="现上架状态" width="80"></el-table-column>
          <el-table-column prop="statusBef" label="原审核状态" width="80"></el-table-column>
          <el-table-column prop="statusNow" label="现审核状态" width="80"></el-table-column>
          <el-table-column prop="auditor" label="审核人员" width="80"></el-table-column>
          <el-table-column prop="auditTime" label="审核时间" width="80"></el-table-column>

                    <el-table-column
                            label="操作"  >
                        <template slot-scope="scope">
                            <el-button @click="edit(scope.row.id)" size="mini" type="primary" size="small">修改</el-button>
                            <el-button @click="dele(scope.row.id)" size="mini" type="danger" size="small">删除</el-button>
                        </template>
                    </el-table-column>
            </el-table>
            <div class="pagination-container">
                <el-pagination
                        class="pagiantion"
                        @size-change="fetchData"
                        @current-change="fetchData"
                        :current-page.sync="currentPage"
                        :page-sizes="[10, 20, 30, 40]"
                        :page-size="size"
                        layout="total, sizes, prev, pager, next, jumper"
                        :total="total">
                </el-pagination>
            </div>
            <div class="add-form">
                <!--弹出窗口-->
                <el-dialog  title="编辑" :visible.sync="formVisible" >
                    <el-form label-width="80px">
                                <el-form-item label="spu商品的id"><el-input v-model="pojo.spuId"></el-input></el-form-item>
        <el-form-item label="原价格"><el-input v-model="pojo.priceBef"></el-input></el-form-item>
        <el-form-item label="现价格"><el-input v-model="pojo.priceNow"></el-input></el-form-item>
        <el-form-item label="促销前"><el-input v-model="pojo.onSaleBef"></el-input></el-form-item>
        <el-form-item label="促销后"><el-input v-model="pojo.onSaleNow"></el-input></el-form-item>
        <el-form-item label="赠送匠币前"><el-input v-model="pojo.presBef"></el-input></el-form-item>
        <el-form-item label="赠送匠币后"><el-input v-model="pojo.presNow"></el-input></el-form-item>
        <el-form-item label="匠币购买金额前"><el-input v-model="pojo.buyBef"></el-input></el-form-item>
        <el-form-item label="匠币购买金额后"><el-input v-model="pojo.buyNow"></el-input></el-form-item>
        <el-form-item label="原上架状态"><el-input v-model="pojo.isMarketableBef"></el-input></el-form-item>
        <el-form-item label="现上架状态"><el-input v-model="pojo.isMarketableNow"></el-input></el-form-item>
        <el-form-item label="原审核状态"><el-input v-model="pojo.statusBef"></el-input></el-form-item>
        <el-form-item label="现审核状态"><el-input v-model="pojo.statusNow"></el-input></el-form-item>
        <el-form-item label="审核人员"><el-input v-model="pojo.auditor"></el-input></el-form-item>
        <el-form-item label="审核时间"><el-input v-model="pojo.auditTime"></el-input></el-form-item>

                            <!-- 图片上传代码 如页面有图片上传功能放开注释 ****
                            <el-form-item label="图片">
                                <el-upload
                                        class="avatar-uploader"
                                        action="/upload/native.do"
                                        :show-file-list="false"
                                        :on-success="handleAvatarSuccess"
                                        :before-upload="beforeAvatarUpload">
                                    <img v-if="imageUrl" :src="imageUrl" class="avatar">
                                    <i v-else class="el-icon-plus avatar-uploader-icon"></i>
                                </el-upload>
                            </el-form-item>
                            -->

                            <el-form-item>
                                <el-button type="primary" @click="save()">保存</el-button>
                                <el-button @click="formVisible = false" >关闭</el-button>
                            </el-form-item>
                    </el-form>
                </el-dialog>
            </div>

        </div>
    </div>


</div>
</body>
<script src="/js/vue.js"></script>
<script src="/js/axios.js"></script>
<script src="/js/elementui.js"></script>
<script>
     new Vue({
        el: '#app',
        data(){
            return {
                tableData: [],
                currentPage: 1,
                total: 10,
                size: 10,
                searchMap: {},
                pojo: {},
                formVisible: false,
                imageUrl: ''
            }
        },
        created(){
            this.fetchData();
        },
        methods:{
            fetchData (){
                axios.post(`/productlog/findPage.do?page=${this.currentPage}&size=${this.size}`,this.searchMap).then(response => {
                    this.tableData = response.data.rows;
                    this.total = response.data.total;
                });
            },
            save (){
                // this.pojo.image= this.imageUrl; //如页面有图片上传功能放开注释
                axios.post(`/productlog/${this.pojo.id==null?'add':'update'}.do`,this.pojo).then(response => {
                    this.fetchData (); //刷新列表
                    this.formVisible = false ;//关闭窗口
                });
            },
            edit (id){
                this.formVisible = true // 打开窗口
                // 调用查询
                axios.get(`/productlog/findById.do?id=${id}`).then(response => {
                    this.pojo = response.data;
                    // this.imageUrl=this.pojo.image //显示图片  如页面有图片上传功能放开注释
                })
            },
            dele (id){
                this.$confirm('确定要删除此记录吗?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then( () => {
                    axios.get(`/productlog/delete.do?id=${id}`).then(response => {
                        this.fetchData (); //刷新列表
                    })
                })
            },
			/* ****图片上传相关代码  如页面有图片上传功能放开注释 **** 
            handleAvatarSuccess(res, file) {
                this.imageUrl = file.response;
            },
            beforeAvatarUpload(file) {
                const isJPG = file.type === 'image/jpeg';
                const isLt2M = file.size / 1024 / 1024 < 2;

                if (!isJPG) {
                    this.$message.error('上传头像图片只能是 JPG 格式!');
                }
                if (!isLt2M) {
                    this.$message.error('上传头像图片大小不能超过 2MB!');
                }
                return isJPG && isLt2M;
            }*/
        }
    })
</script>
</html>
